package com.aaron.demo1.megaeyes;


import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.aaron.demo1.test.megaeyes.model.PTZControl;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class Test {


    public static final String USER_NAME = "AdminJQR";
    public static final String PASSWORD = "Zqqqy1357";
    public static final String CLIENT_TYPE = "winpc";
    public static final String USER_AGENT = "winpc";
    public static final String CONTENT_TYPE = "application/json;charset=UTF-8";
    public static final String IP_ADDR = "https://61.151.156.1:8282";
//    public static final String IP_ADDR = "https://10.200.1.71:8320";

    private static final String GET_TOKEN_URL = "/videoService/accounts/authorize";


    public static void test(){


        HttpRequest postReq = HttpUtil.createPost(IP_ADDR + GET_TOKEN_URL);
        HashMap<String,String> headers = new HashMap<String,String>();
        headers.put("Content-Type",CONTENT_TYPE);
        headers.put("User-Agent",USER_AGENT);
//        postReq.header();
        postReq.addHeaders(headers);
        Map<String, List<String>> headers1 = postReq.headers();
        List<String> list = headers1.get("User-Agent");
        list.remove(0);
        HashMap<String, String> body = new HashMap<>();
        body.put("userName", USER_NAME);
        body.put("clientType", CLIENT_TYPE);
        postReq.body(JSONUtil.toJsonStr(body));
        String response = postReq.timeout(4 * 1000).execute().body();

        System.out.println();

    }

    public static void main(String[] args) {
        test2();
    }

    public static void test2(){

        PTZControl ptz = new PTZControl();
        ptz.setPan(0.1111);
        ptz.setTilt(0.5);
        ptz.setZoom(-0.5);
        ptz.setDuration(100);
        System.out.println(JSONObject.toJSONString(ptz));

    }

}
